using Godot;

namespace Arcane.Source.Combat.StatusEffects
{
    public class Shield(int duration) : TimerEffect(duration)
    {
        public readonly static StringName MODIFIER = "shield";
        private Modifier _modifier;
        public override void OnStack(ITrigger trigger)
        {
            if (trigger is not Shield other) return;

            _timer += other._timer;
            Count += 1;

            if (_modifier != null)
                _modifier.value = -0.1f * Count;
        }

        public override void OnReady(Entity host)
        {
            _modifier = new Modifier
            {
                type = ModifierType.Hurt,
                op = ModifierOp.Mul,
                value = -0.1f,
            };

            host.AddModifier(MODIFIER, _modifier);
        }

        public override void OnRemove(Entity host)
        {
            host.RemoveModifier(MODIFIER);
        }
    }
}